ActionController::Routing::Routes.draw do |map|
  # Mappiamo ogni tipo di utente ad un suo controller per modificarsi il profilo
  map.resource :administrator
  map.resource :customer
  map.resource :restaurant
  map.resource :delivery_man
  map.resource :pizza_maker
  # Queste righe dovrebbero servire per autenticare gli utenti
  map.resource :account_session
  
  map.products "products", :controller => "products", :action => "index"
  #risorse dell'amministratore
  #map.products_admin "admin/products", :controller => "products", :action => "admin"
  #map.restaurants_admin "admin/restaurants", :controller => "restaurants", :action => "admin"

  #paths per gli account personali dei pizza_maker
  #map.edit_pizza_maker "pizza_maker/edit", :controller => "pizza_makers", :action => "edit_self"
  #map.update_pizza_maker "pizza_maker/update", :controller => "pizza_makers", :action => "update_self"

  #paths per gli account personali dei delivery_men
  #map.edit_delivery_man "delivery_man/edit", :controller => "delivery_men", :action => "edit_self"
  #map.update_delivery_man "delivery_man", :controller => "delivery_men", :action => "update_self"

  # Azioni di visualizzazione delle pizzerie
  map.restaurants "restaurants", :controller => "restaurants", :action => "index"
  map.restaurants_map "restaurants/map", :controller => "restaurants", :action => "map"
  #map.delete_restaurants "admin/restaurants/:id/delete", :controller => "restaurants", :action => "destroy"

  # Routing per le azioni di gestione della pizzeria
  map.namespace :restaurant do |restaurant|
    restaurant.resources :delivery_men
    restaurant.resources :pizza_makers
  end

  # Routing per l'amministrazione:
  map.namespace :admin do |admin|
    admin.resources :restaurants
    admin.resources :products
    admin.resources :administrators
  end

  map.namespace :customer do |customer|
    customer.resources :orders
    customer.addproduct_to_order "orders/addproduct/:id", :controller => "orders", :action => "addproduct", :method => :get
  end
  
  # optional, this just sets the root route, la home page la renderizza application
  # non c'è bisogno di definirne l'azione nel controller, rails automaticamente
  # richiama la vista
  map.root :controller => "application", :action => "index"
  map.about "about", :controller => "application", :action => "about"

  # The priority is based upon order of creation: first created -> highest priority.

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  
  # Sample resource route with more complex sub-resources
  #   map.resources :products do |products|
  #     products.resources :comments
  #     products.resources :sales, :collection => { :recent => :get }
  #   end

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  # map.root :controller => "welcome"

  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing or commenting them out if you're using named routes and resources.
  #map.connect ':controller/:action/:id'
  #map.connect ':controller/:action/:id.:format'
end
